package com.chuan.it_market.service.impl;

import com.chuan.it_market.dao.BuyerDao;
import com.chuan.it_market.dao.SellerDao;
import com.chuan.it_market.pojo.entity.Buyer;
import com.chuan.it_market.pojo.entity.Seller;
import com.chuan.it_market.service.LoginService;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class LoginServiceImpl implements LoginService {
    @Resource
    SellerDao sellerDao;
    @Resource
    BuyerDao buyerDao;


    @Override
    public Seller login(Seller seller){

        return sellerDao.selectByPhoneAndPassowrd(seller.getPhone(),seller.getPassword());

    }

    @Override
    public Buyer login2(Buyer buyer) {
        return buyerDao.selectByPhoneAndPassword(buyer.getPhone(),buyer.getPassword());
    }

    @Override
    public int sellerRegister(Seller seller) {
        return sellerDao.insert(seller);
    }

    @Override
    public void updatePassword(Integer sno, String newPassword) {
        sellerDao.updatePasswordBysno(sno,newPassword);
    }

    @Override
    public void updatePassword2(Integer bno, String newPassword) {
        buyerDao.updatePasswordBybno(bno,newPassword);
    }

    @Override
    public Seller selectSellerByPhone(String phone) {
        return sellerDao.selectSellerByPhone(phone);
    }

    @Override
    public Buyer selectBuyerByPhone(String phone) {
        return buyerDao.selectBuyerByPhone(phone);
    }

    @Override
    public int BuyerRegister(Buyer buyer) {
        return buyerDao.insert(buyer);
    }
}
